"""
魔术方法 命名规则 __xxx__
"""


class Student:

    def __init__(self, name, age):
        self.name = name
        self.age = age

    # toString方法
    def __str__(self):
        return f"Student({self.name},{self.age})"

    # 小于，大于对象比较
    def __lt__(self, other):
        return self.age > other.age

    # 小于等于，大于等于对象比较
    def __le__(self, other):
        return self.age >= other.age

    # 等于比较, 如果没有实现，比较的是内存地址
    def __eq__(self, other):
        return self.age == other.age


s = Student("张三", 10)
s2 = Student("李四", 15)
print(str(s))

print(s > s2)
print(s < s2)

print(s <= s2)
print(s >= s2)

print(s == s2)
